﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UMLTouch.DomainRecognition.Factory;
using UMLTouch.DomainRecognition.Engines;
using UMLTouch.DomainRecognition.ShapeRecognition;
using UMLTouch.Domain.ClassDiagram.Patterns;
using UMLTouch.DomainRecognition.SegmentationAlgorithms;
using UMLTouch.Core.UI;
using System.Windows;
using System.Reflection;
using UMLTouch.Core.ViewModel;
using UMLTouch.Domain.ClassDiagram.ViewModels;

namespace UMLTouch.Domain.ClassDiagram
{
    public class ClassDiagramRecognition : IDomainRecognition
    {

        public RecognitionEngine GetRecognitionEngine()
        {
            ShapeRecognizer shapeRecognizer = new ClassDiagramRecognizer();
            ISegmentationAlgorithm segmentationAlgorithm = new PersonnalAlgorithm();
            RecognitionEngine engine = new RecognitionEngine(shapeRecognizer, segmentationAlgorithm);

            return engine;
        }

        public IDiagramContext CreateContext(string name)
        {
            return new ClassDiagramContext(name);
        }

        public DiagramContextViewModel CreateContextViewModel(String name)
        {
            return CreateContextViewModel(CreateContext(name) as ClassDiagramContext);
        }

        public DiagramContextViewModel CreateContextViewModel(IDiagramContext DiagramContext)
        {
            DiagramContextViewModel ret = null;
            if (DiagramContext is ClassDiagramContext)
            {
                ret = new ClassDiagramContextViewModel(DiagramContext as ClassDiagramContext);
            }

            return ret;
        }

       

        #region IDomainRecognition Members


        public string Description
        {
            get { return "Creates Class diagrams"; }
        }

        public string DisplayName
        {
            get { return "Class Diagram"; }
        }

        //private static void LoadRessources()
        //{

        //    try
        //    {
        //        string packUri = String.Format(@",,,ujhvgkjv/{0}", "Dictionnary.xaml");

        //        Uri uri = new Uri(packUri, UriKind.Relative);

               
        //        ResourceDictionary dic = Application.LoadComponent(uri) as ResourceDictionary;
        //        Application.Current.Resources.MergedDictionaries.Add(dic);
        //    }
        //    catch (Exception ex)
        //    {


        //    }
        //}

        public string[] ResourceFiles
        {
            get { return new string[] { "Dictionnary.xaml" }; }
        }

        #endregion

       

        public string DefaultContextName
        {
            get { return "Class Diagram"; }
        }

        
    }
}
